import 'package:dio/dio.dart';
import 'package:sonora/models/sj_login_response_data.dart';
import 'package:sonora/network/sj_network.dart';
import 'package:sonora/services/sj_api_client.dart';

class SjApiLoginService {
  final SjApiClient _client;

  SjApiLoginService._internal(this._client);

  static final SjApiLoginService _instance =
      SjApiLoginService._internal(SjApiClient(clientDio()));

  factory SjApiLoginService() {
    return _instance;
  }

  static Dio clientDio() {
    Dio dio = SjNetwork().clientDio;
    dio.options.headers.addAll({
      'content-type': 'application/x-www-form-urlencoded',
    });
    return dio;
  }

  SjApiClient get client => _client;

  Future<SjLoginResponseData> appleLogin(String toke) async {
    int oauthType = 3;
    SjLoginResponseData response = await client.appleLogin(oauthType, toke);
    return response;
  }

  Future<SjLoginResponseData> fastLogin(String toke) async {
    int oauthType = 4;
    SjLoginResponseData response = await client.appleLogin(oauthType, toke);
    return response;
  }
}
